﻿<%@ Page Title="User Management" Language="C#" MasterPageFile="~/Lab.master" AutoEventWireup="true" CodeFile="UserManagement.aspx.cs" Inherits="UserManagement" %>

<asp:Content ID="Content1" ContentPlaceHolderID="HeadContent" runat="Server">
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="BodyContent" runat="Server">
    <div class="col-md-12 col-sm-12 col-xs-12">
        <div class="x_panel">
            <div class="x_title">
                <h2>Users</h2>
                <ul class="nav navbar-right panel_toolbox">
                    <li><a class="collapse-link"><i class="fa fa-chevron-up"></i></a>
                    </li>
                    <li class="dropdown">
                        <a href="#" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-expanded="false"><i class="fa fa-wrench"></i></a>
                        <ul class="dropdown-menu" role="menu">
                            <li><a href="#">Settings 1</a>
                            </li>
                            <li><a href="#">Settings 2</a>
                            </li>
                        </ul>
                    </li>
                    <li><a class="close-link"><i class="fa fa-close"></i></a>
                    </li>
                </ul>
                <div class="clearfix"></div>
            </div>

            <div class="x_content">
                <div class="table-responsive">
                    <asp:Repeater ID="userList" runat="server">
                        <HeaderTemplate>
                            <table class="table table-striped jambo_table bulk_action" id="tblEditable">
                                <thead>
                                    <tr class="headings">
                                        <th class="column-title">ID</th>
                                        <th class="column-title">NIP</th>
                                        <th class="column-title">Nama</th>
                                        <th class="column-title">Username</th>
                                        <th class="column-title">Password</th>
                                        <th class="column-title">Jenis User</th>
                                        <th class="column-title">Aktif </th>
                                    </tr>
                                </thead>
                                <tbody>
                        </HeaderTemplate>
                        <ItemTemplate>
                                    <tr class="even pointer">
                                        <td class=" "><%# DataBinder.Eval(Container.DataItem, "ID") %></td>
                                        <td class=" "><%# DataBinder.Eval(Container.DataItem, "NIP") %></td>
                                        <td class=" "><%# DataBinder.Eval(Container.DataItem, "NAMA") %></td>
                                        <td class=" "><%# DataBinder.Eval(Container.DataItem, "USERNAME") %></td>
                                        <td class=" "><%# DataBinder.Eval(Container.DataItem, "PASSWORD") %></td>
                                        <td class=" "><%# DataBinder.Eval(Container.DataItem, "JENIS_USER") %></td>
                                        <td class="a-right a-right "><%# DataBinder.Eval(Container.DataItem, "ACTIVE") %></td>
                                    </tr>
                        </ItemTemplate>
                        <AlternatingItemTemplate>
                                    <tr class="odd pointer">
                                        <td class=" "><%# DataBinder.Eval(Container.DataItem, "ID") %></td>
                                        <td class=" "><%# DataBinder.Eval(Container.DataItem, "NIP") %></td>
                                        <td class=" "><%# DataBinder.Eval(Container.DataItem, "NAMA") %></td>
                                        <td class=" "><%# DataBinder.Eval(Container.DataItem, "USERNAME") %></td>
                                        <td class=" "><%# DataBinder.Eval(Container.DataItem, "PASSWORD") %></td>
                                        <td class=" "><%# DataBinder.Eval(Container.DataItem, "JENIS_USER") %></td>
                                        <td class="a-right a-right "><%# DataBinder.Eval(Container.DataItem, "ACTIVE") %></td>
                                    </tr>
                        </AlternatingItemTemplate>
                        <FooterTemplate>
                                    </tbody>
                                </table>
                        </FooterTemplate>
                    </asp:Repeater>
                </div>
            </div>
        </div>

        <div class="x_panel">
            <div class="x_title">
                <h2>Tambah User</h2>
                <ul class="nav navbar-right panel_toolbox">
                    <li><a class="collapse-link"><i class="fa fa-chevron-up"></i></a>
                    </li>
                    <li class="dropdown">
                        <a href="#" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-expanded="false"><i class="fa fa-wrench"></i></a>
                        <ul class="dropdown-menu" role="menu">
                            <li><a href="#">Settings 1</a>
                            </li>
                            <li><a href="#">Settings 2</a>
                            </li>
                        </ul>
                    </li>
                    <li><a class="close-link"><i class="fa fa-close"></i></a>
                    </li>
                </ul>
                <div class="clearfix"></div>
            </div>
            <div class="x_content">
                <br />
                <form id="myForm" runat="server" class="form-horizontal form-label-left" method="post">
                    <div class="form-group">
                        <label class="control-label col-md-3 col-sm-3 col-xs-12">NIP<span class="required">*</span></label>
                        <div class="col-md-6 col-sm-6 col-xs-12">
                            <input id="nip" runat="server" class="form-control col-md-7 col-xs-12" type="text" name="nip" required >
                        </div>
                    </div>

                    <div class="form-group">
                        <label class="control-label col-md-3 col-sm-3 col-xs-12">Nama<span class="required">*</span></label>
                        <div class="col-md-6 col-sm-6 col-xs-12">
                            <input id="nama" runat="server" class="form-control col-md-7 col-xs-12" type="text" name="nama" required >
                        </div>
                    </div>

                    <div class="form-group">
                        <label class="control-label col-md-3 col-sm-3 col-xs-12">Username<span class="required">*</span></label>
                        <div class="col-md-6 col-sm-6 col-xs-12">
                            <input id="username" runat="server" class="form-control col-md-7 col-xs-12" type="text" name="username" required >
                        </div>
                    </div>

                    <div class="form-group">
                        <label class="control-label col-md-3 col-sm-3 col-xs-12">Password<span class="required">*</span></label>
                        <div class="col-md-6 col-sm-6 col-xs-12">
                            <input id="password" runat="server" class="form-control col-md-7 col-xs-12" type="password" name="password" required >
                        </div>
                    </div>

                    <div class="form-group">
                        <label class="control-label col-md-3 col-sm-3 col-xs-12">Ulangi Password<span class="required">*</span></label>
                        <div class="col-md-6 col-sm-6 col-xs-12">
                            <input id="password2" runat="server" class="form-control col-md-7 col-xs-12" type="password" name="password2" required >
                        </div>
                    </div>

                    <div class="form-group">
                        <label class="control-label col-md-3 col-sm-3 col-xs-12">Jenis User<span class="required">*</span>
                        </label>
                        <div class="col-md-6 col-sm-6 col-xs-12">
                            <select class="select2_jenis form-control" tabindex="-1" name="jenis" id="jenis" required>
                                <asp:Repeater runat="server" ID="lstJenis">
                                    <HeaderTemplate>
                                        <option></option>
                                    </HeaderTemplate>
                                    <ItemTemplate>
                                        <option value="<%# DataBinder.Eval(Container.DataItem, "ID") %>"><%# DataBinder.Eval(Container.DataItem, "JENIS_USER") %></option>
                                    </ItemTemplate>
                                </asp:Repeater>
                              </select>
                        </div>
                    </div>

                    <div class="form-group">
                        <label class="control-label col-md-3 col-sm-3 col-xs-12">Laboratorium<span class="required">*</span>
                        </label>
                        <div class="col-md-6 col-sm-6 col-xs-12">
                            <select class="select2_lab form-control" tabindex="-1" name="lab" id="lab" required>
                                <asp:Repeater runat="server" ID="lstLab">
                                    <HeaderTemplate>
                                        <option></option>
                                    </HeaderTemplate>
                                    <ItemTemplate>
                                        <option value="<%# DataBinder.Eval(Container.DataItem, "ID") %>"><%# DataBinder.Eval(Container.DataItem, "NAMA") %></option>
                                    </ItemTemplate>
                                </asp:Repeater>
                              </select>
                        </div>
                    </div>

                    <div class="form-group">
                        <div class="col-md-6 col-sm-6 col-xs-12 col-md-offset-3">
                            <asp:Button runat="server" ID="btnAdd" CssClass="btn btn-success" Text="Tambah User" OnClick="btnAdd_Click" />
                        </div>
                    </div>
                </form>
            </div>
        </div>
    </div>
</asp:Content>
<asp:Content ID="Content3" ContentPlaceHolderID="BodyFooterContainer" runat="Server">
    <script type="text/javascript">
        $('#tblEditable').Tabledit({
            url: 'DataManagement.aspx?ManageUser',
            deleteButton: true,
            saveButton: true,
            autoFocus: false,
            hideIdentifier: true,
            restoreButton: false,
            columns: {
                identifier: [0, 'id'],
                //editable: [[1, 'nip'], [2, 'nama'], [3, 'username'], [4, 'password'], [5, 'jenis'], [6, 'active']]
                editable: [[2, 'nama'], [4, 'password'] ]
        },
            onSuccess: function (data, textStatus, jqXHR) {
                //console.log('onSuccess(data, textStatus, jqXHR)');
                //console.log(data);
                //console.log(textStatus);
                //console.log(jqXHR);

                new PNotify({
                    title: 'User Management',
                    text: 'Data sudah berhasil diubah',
                    type: 'success',
                    styling: 'bootstrap3'
                });
            },
            onFail: function (jqXHR, textStatus, errorThrown) {
                //console.log('onFail(jqXHR, textStatus, errorThrown)');
                //console.log(jqXHR);
                //console.log(textStatus);
                //console.log(errorThrown);

                new PNotify({
                    title: 'User Management',
                    text: 'Gagal mengubah data',
                    type: 'error',
                    styling: 'bootstrap3'
                });
            }
        });
    </script>
</asp:Content>